package innerclassdemo;

class OuterClass {
    public int data1 = 10;
    private int data2 = 20;
    public static int data3 = 30;

    class InnerClass {
        public int data4;
        private int data5;
        public static final int data6 = 60;

        public InnerClass() {
            System.out.println("InnerClass的构造方法");
        }

        public void method() {
            System.out.println("InnerClass的method方法");
            System.out.println(data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }

//        public static void func() {
//
//        } // 内部类不能有静态方法
    }

    // 内部类的静态方法
    public static void func1() {

    }
}

public class TestDemo {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        System.out.println(outerClass.data1);

        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        OuterClass.InnerClass innerClass1 = new OuterClass().new InnerClass();

    }
}